NexusPi Git Node
LoRaInterface.h HEAD (592c826d) Text, 3.75 KB
T8b949e// Copyright (C) 2026, Chad Attermann
T8b949e// This program is free software: you can redistribute it and/or modify
T8b949e// it under the terms of the GNU General Public License as published by
T8b949e// the Free Software Foundation, either version 3 of the License, or
T8b949e// (at your option) any later version.
T8b949e// This program is distributed in the hope that it will be useful,
T8b949e// but WITHOUT ANY WARRANTY; without even the implied warranty of
T8b949e// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
T8b949e// GNU General Public License for more details.
T8b949e// You should have received a copy of the GNU General Public License
T8b949e// along with this program. If not, see <https://www.gnu.org/licenses/>.
Tff7b72#Tff7b72pragma once
Tff7b72#Tff7b72include T8b949e"Config.h"
Tff7b72#Tff7b72include T8b949e"Boards.h"
T8b949e// CBA NOTE: Can *NOT* include "Utilities.h" here due to potential conflict with <MsgPack.h>
T8b949e//#include "Utilities.h"
Tff7b72#Tff7b72include T8b949e<microReticulum.h>
Tff7b72extern Tffa657uint32_t Te6edf3lora_bitrateTb4b4b4;
Tff7b72extern Tff7b72volatile Tffa657uint8_t Te6edf3queue_heightTb4b4b4;
Tff7b72extern Tff7b72volatile Tffa657uint16_t Te6edf3queued_bytesTb4b4b4;
Tff7b72extern Tff7b72volatile Tffa657uint16_t Te6edf3queue_cursorTb4b4b4;
Tff7b72extern Tff7b72volatile Tffa657uint16_t Te6edf3current_packet_startTb4b4b4;
Tff7b72typedef Tff7b72struct T56d364FIFOBuffer16 Te6edf3FIFOBuffer16Tb4b4b4;
Tff7b72extern Te6edf3FIFOBuffer16 Te6edf3packet_startsTb4b4b4;
Tff7b72extern Te6edf3FIFOBuffer16 Te6edf3packet_lengthsTb4b4b4;
Tff7b72extern Tffa657uint8_t Te6edf3packet_queueTb4b4b4[Tb4b4b4]Tb4b4b4;
Tff7b72extern Tffa657bool Td2a8fffifo16_isfullTb4b4b4(Tff7b72const Te6edf3FIFOBuffer16 Tff7b72*Te6edf3fTb4b4b4)Tb4b4b4;
Tff7b72extern Tffa657void Td2a8fffifo16_pushTb4b4b4(Te6edf3FIFOBuffer16 Tff7b72*Te6edf3fTb4b4b4, Tffa657uint16_t Te6edf3cTb4b4b4)Tb4b4b4;
Te6edf3class Te6edf3LoRaInterface Tff7b72: Te6edf3public Te6edf3RNSTff7b72:Tff7b72:Te6edf3InterfaceImpl Tb4b4b4{
Te6edf3publicTff7b72:
Te6edf3LoRaInterfaceTb4b4b4(Tff7b72const Tffa657char Tff7b72*Te6edf3nameTb4b4b4) Tff7b72: Te6edf3RNSTff7b72:Tff7b72:Te6edf3InterfaceImplTb4b4b4(Te6edf3nameTb4b4b4) Tb4b4b4{
Te6edf3_IN Tff7b72= Tffa657trueTb4b4b4;
Te6edf3_OUT Tff7b72= Tffa657trueTb4b4b4;
Te6edf3_HW_MTU Tff7b72= T79c0ff508Tb4b4b4;
Te6edf3_bitrate Tff7b72= Te6edf3lora_bitrateTb4b4b4;
Tb4b4b4}
Te6edf3LoRaInterfaceTb4b4b4(Tb4b4b4) Tff7b72: Te6edf3LoRaInterfaceTb4b4b4(Ta5d6ff"Ta5d6ffLoRaInterfaceTa5d6ff"Tb4b4b4) Tb4b4b4{Tb4b4b4}
Te6edf3virtual Tff7b72~Te6edf3LoRaInterfaceTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3_name Tff7b72= Ta5d6ff"Ta5d6ffdeletedTa5d6ff"Tb4b4b4;
Tb4b4b4}
Te6edf3protectedTff7b72:
Te6edf3virtual Tffa657void Te6edf3handle_incomingTb4b4b4(Tff7b72const Te6edf3RNSTff7b72:Tff7b72:Te6edf3BytesTff7b72& Te6edf3dataTb4b4b4) Tb4b4b4{
Te6edf3TRACEFTb4b4b4(Ta5d6ff"Ta5d6ffLoRaInterface.handle_incoming: (%u bytes) data: %sTa5d6ff"Tb4b4b4, Te6edf3dataTb4b4b4.Te6edf3sizeTb4b4b4(Tb4b4b4)Tb4b4b4, Te6edf3dataTb4b4b4.Te6edf3toHexTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3c_strTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4;
T8b949e//TRACE("LoRaInterface.handle_incoming: sending packet to rns...");
Te6edf3try Tb4b4b4{
Te6edf3InterfaceImplTff7b72:Tff7b72:Te6edf3handle_incomingTb4b4b4(Te6edf3dataTb4b4b4)Tb4b4b4;
Tb4b4b4}
Te6edf3catch Tb4b4b4(Tff7b72const Te6edf3stdTff7b72:Tff7b72:Te6edf3bad_allocTff7b72&Tb4b4b4) Tb4b4b4{
Te6edf3ERRORTb4b4b4(Ta5d6ff"Ta5d6ffLoRaInterface::handle_incoming: bad_alloc - out of memoryTa5d6ff"Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Te6edf3catch Tb4b4b4(Te6edf3stdTff7b72:Tff7b72:Te6edf3exceptionTff7b72& Te6edf3eTb4b4b4) Tb4b4b4{
Te6edf3ERRORFTb4b4b4(Ta5d6ff"Ta5d6ffLoRaInterface::handle_incoming: %sTa5d6ff"Tb4b4b4, Te6edf3eTb4b4b4.Te6edf3whatTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4;
Tb4b4b4}
Tb4b4b4}
Te6edf3virtual Tffa657bool Te6edf3send_outgoingTb4b4b4(Tff7b72const Te6edf3RNSTff7b72:Tff7b72:Te6edf3BytesTff7b72& Te6edf3dataTb4b4b4) Tb4b4b4{
T8b949e// CBA NOTE header will be addded later by transmit function
Te6edf3TRACEFTb4b4b4(Ta5d6ff"Ta5d6ffLoRaInterface.send_outgoing: (%u bytes) data: %sTa5d6ff"Tb4b4b4, Te6edf3dataTb4b4b4.Te6edf3sizeTb4b4b4(Tb4b4b4)Tb4b4b4, Te6edf3dataTb4b4b4.Te6edf3toHexTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3c_strTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4;
Te6edf3try Tb4b4b4{
T8b949e//TRACE("LoRaInterface.send_outgoing: adding packet to outgoing queue...");
Tff7b72for Tb4b4b4(Tffa657size_t Te6edf3i Tff7b72= T79c0ff0Tb4b4b4; Te6edf3i Tff7b72< Te6edf3dataTb4b4b4.Te6edf3sizeTb4b4b4(Tb4b4b4)Tb4b4b4; Te6edf3iTff7b72+Tff7b72+Tb4b4b4) Tb4b4b4{
Tff7b72if Tb4b4b4(Te6edf3queue_height Tff7b72< Te6edf3CONFIG_QUEUE_MAX_LENGTH Tff7b72&Tff7b72& Te6edf3queued_bytes Tff7b72< Te6edf3CONFIG_QUEUE_SIZETb4b4b4) Tb4b4b4{
Te6edf3queued_bytesTff7b72+Tff7b72+Tb4b4b4;
Te6edf3packet_queueTb4b4b4[Te6edf3queue_cursorTff7b72+Tff7b72+Tb4b4b4] Tff7b72= Te6edf3dataTb4b4b4.Te6edf3dataTb4b4b4(Tb4b4b4)Tb4b4b4[Te6edf3iTb4b4b4]Tb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3queue_cursor Tff7b72=Tff7b72= Te6edf3CONFIG_QUEUE_SIZETb4b4b4) Te6edf3queue_cursor Tff7b72= T79c0ff0Tb4b4b4;
Tb4b4b4}
Tb4b4b4}
Tff7b72if Tb4b4b4(Tff7b72!Te6edf3fifo16_isfullTb4b4b4(Tff7b72&Te6edf3packet_startsTb4b4b4) Tff7b72&Tff7b72& Te6edf3queued_bytes Tff7b72< Te6edf3CONFIG_QUEUE_SIZETb4b4b4) Tb4b4b4{
Tffa657uint16_t Te6edf3s Tff7b72= Te6edf3current_packet_startTb4b4b4;
Tffa657int16_t Te6edf3e Tff7b72= Te6edf3queue_cursorT79c0ff-1Tb4b4b4; Tff7b72if Tb4b4b4(Te6edf3e Tff7b72=Tff7b72= T79c0ff-1Tb4b4b4) Te6edf3e Tff7b72= Te6edf3CONFIG_QUEUE_SIZET79c0ff-1Tb4b4b4;
Tffa657uint16_t Te6edf3lTb4b4b4;
Tff7b72if Tb4b4b4(Te6edf3s Tff7b72!Tff7b72= Te6edf3eTb4b4b4) Tb4b4b4{
Te6edf3l Tff7b72= Tb4b4b4(Te6edf3s Tff7b72< Te6edf3eTb4b4b4) Tff7b72? Te6edf3e Tff7b72- Te6edf3s Tff7b72+ T79c0ff1 Tff7b72: Te6edf3CONFIG_QUEUE_SIZE Tff7b72- Te6edf3s Tff7b72+ Te6edf3e Tff7b72+ T79c0ff1Tb4b4b4;
Tb4b4b4} Tff7b72else Tb4b4b4{
Te6edf3l Tff7b72= T79c0ff1Tb4b4b4;
Tb4b4b4}
Tff7b72if Tb4b4b4(Te6edf3l Tff7b72>Tff7b72= Te6edf3MIN_LTb4b4b4) Tb4b4b4{
Te6edf3queue_heightTff7b72+Tff7b72+Tb4b4b4;
Te6edf3fifo16_pushTb4b4b4(Tff7b72&Te6edf3packet_startsTb4b4b4, Te6edf3sTb4b4b4)Tb4b4b4;
Te6edf3fifo16_pushTb4b4b4(Tff7b72&Te6edf3packet_lengthsTb4b4b4, Te6edf3lTb4b4b4)Tb4b4b4;
Te6edf3current_packet_start Tff7b72= Te6edf3queue_cursorTb4b4b4;
Tb4b4b4}
Tb4b4b4}
T8b949e// Perform post-send housekeeping
Te6edf3InterfaceImplTff7b72:Tff7b72:Te6edf3handle_outgoingTb4b4b4(Te6edf3dataTb4b4b4)Tb4b4b4;
Tb4b4b4}
Te6edf3catch Tb4b4b4(Tff7b72const Te6edf3stdTff7b72:Tff7b72:Te6edf3bad_allocTff7b72&Tb4b4b4) Tb4b4b4{
Te6edf3ERRORTb4b4b4(Ta5d6ff"Ta5d6ffLoRaInterface::send_outgoing: bad_alloc - out of memoryTa5d6ff"Tb4b4b4)Tb4b4b4;
Tff7b72return Tffa657falseTb4b4b4;
Tb4b4b4}
Te6edf3catch Tb4b4b4(Te6edf3stdTff7b72:Tff7b72:Te6edf3exceptionTff7b72& Te6edf3eTb4b4b4) Tb4b4b4{
Te6edf3ERRORFTb4b4b4(Ta5d6ff"Ta5d6ffLoRaInterface::send_outgoing: %sTa5d6ff"Tb4b4b4, Te6edf3eTb4b4b4.Te6edf3whatTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4;
Tff7b72return Tffa657falseTb4b4b4;
Tb4b4b4}
Tff7b72return Tffa657trueTb4b4b4;
Tb4b4b4}
Tb4b4b4}Tb4b4b4;
Served by rngit 1.5.2 - Generated in 0.02s